package ve.gob.ine.censo.servlet;

import java.io.IOException;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 
 * ?reporte=nombre_reporte &tipo=PDF o XLS &ps_parametro parametro de string
 * &pi_parametro parametro de integer
 * 
 * http://localhost:8080/ventapiramidal/gen_rep?reporte=detalle_ven&tipo=PDF&
 * ps_codigo=DARO Servlet implementation class gen_rep
 */

public class pago_rep extends HttpServlet {

	private static final long serialVersionUID = 1L;
//	private EjecutaPago ejecutaPago;
	private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
	Log log = LogFactory.getLog(this.getClass());
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
//		PersonalDAO personalDAO = new PersonalDAOImpl(Conexion.config());
		
//		this.ejecutaPago = ((EjecutaPago) request.getSession().getAttribute("EjecutaPago"));

		response.setContentType("text/csv");		
		ServletOutputStream ouputStream = response.getOutputStream();
		ouputStream.println("Fecha, Ced_Enc, Apellido_Enc, Nombre_Enc, Ced_Sup, Apellido_Sup, Nombre_Sup, Entidad, Encuesta/Persona, Sistema, Tipo");

		

		
//		for (Resumen_pagos rp : this.ejecutaPago.getLstPagosHechos()) {
//			empadronador = null;
//			supervisor = null;
//			try {
////				empadronador = personalDAO.selectByPrimaryKey(rp.getIdEmpa());
//				System.out.println("Id Empadronador: " + rp.getIdEmpa());
//				if(empadronador!=null){
////					supervisor = personalDAO.selectByPrimaryKey(empadronador.getIdsupervisor());
//					System.out.println("Id Empadronador: " + rp.getIdEmpa() + " Id Supervisor: " + empadronador.getIdsupervisor());
//				}
////			} catch (SQLException e) {
////				e.printStackTrace();
//			}finally{
//				if(supervisor == null){
//					supervisor = new Personal();
//				}
//			}
//			
//			
//			ouputStream.println(sdf.format(rp.getFechaProgPago())+","+rp.getCedula()+","+rp.getApellido()+","+rp.getNombre()+","+supervisor.getCedula()+","+supervisor.getApellidos()+","+supervisor.getNombre()+","+"69"+","+rp.getTotalViviendas()+",2,"+rp.getTipo());
//		}
		ouputStream.flush();
		ouputStream.close();
	}
}
